package com.gql.datetime;

import org.junit.jupiter.api.Test;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.format.DateTimeFormatter;
import java.time.temporal.TemporalAccessor;

/**
 * description:
 * @author: gql
 * @date: 2022/04
 */
public class LocalDateTest {
    /**
     * now() 获取当前日期、时间、日期+时间
     */
    @Test
    public void localTest(){
        LocalDate localDate = LocalDate.now();
        LocalTime localTime = LocalTime.now();
        LocalDateTime localDateTime = LocalDateTime.now();

        System.out.println("localDate = " + localDate);
        System.out.println("localTime = " + localTime);
        System.out.println("localDateTime = " + localDateTime);
    }

    /**
     * DateTimeFormatter
     */
    @Test
    public void dateTimeFormatterTest(){
        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMMdd");
        String now = formatter.format(LocalDate.now());
        System.out.println("now = " + now);
    }

}
